module Piston
  class Workspace
    include Singleton
    attr_reader :plugins
    attr_accessor :main_window
    
    def initialize
      @plugins = []
    end

    def file_view
      return @file_view if @file_view
      doc_pane = @main_window.find_name('layoutPanel')
      @file_view = Piston::Core::FileView.new(doc_pane)
    end

    def add_commands(cmds)
      cmds.each_pair do |cmd, obj|
        self.class.class_eval "attr_reader :#{cmd}"
        instance_variable_set("@#{cmd}", obj)
      end
    end
  end
end